import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
  state: () => ({
    user: null,
    nowSelectModul: 0,
    bhzs_drawer: false,
  }),
  actions: { //  定义actions，包含setUser、clearUser、setNowSelectModul、toggleBhzsDrawer四个方法
    setUser(user) {
      this.user = user;
    },
    clearUser() {
      this.user = null;
      localStorage.removeItem('token');
    },
    setNowSelectModul(index) {
      this.nowSelectModul = index;
    },
    toggleBhzsDrawer(value) {
      this.bhzs_drawer = value;
    },
  },
});